#Placebo test#

load("Implementation Main Data.Rdata")
set.seed(1015)
n<-1000
coef<-matrix(NA, ncol=3)
data<-na.omit(data[,c("pam_caseid", "nonsig_minor_war_mh", "bin","amnest_init", 
                                "incompatibility", "truth_init", "prisr_init", "powtran_init",
                                "spline_nonsig", "spline_nonsig2", "spline_nonsig3")])

controls<-c("truth_init","prisr_init", "powtran_init",
            "as.factor(incompatibility)",
            "spline_nonsig","spline_nonsig2","spline_nonsig3")

placebo_form<-as.formula(paste("nonsig_minor_war_mh~as.factor(bin)*as.factor(amnest_init)+",
                            paste(controls, collapse="+")))
placebo<-brglm(placebo_form, data=data)
set.seed(1015)
placebo_boot<-cluster_bootstrap(placebo, n=1000, amn="amnest_init", bin="bin")
placebo_plot<-int_plot(placebo, placebo_boot, amn="amnest_init", bin="bin")
plot.dat<-placebo_plot[[2]][3,]

fig15<-ggplot(plot.dat, aes(y=Estimate, x=Effect))+
  coord_flip()+
  geom_point(size=3, position=position_dodge(width=.5))+
  geom_linerange(aes(ymin=LB, ymax=UB))+
  geom_hline(yintercept=0)+
  geom_point(aes(y=-.314, x=Effect), color="red", shape=15, size=3)+
  xlab("")+
  ylab("Marginal Effect of Amnesty on War Recurrence")+
  theme_bw(base_size = 14)
fig15
pdf("Fig15.pdf", width=7, height=4)
print(fig15)
dev.off()

rm(list=setdiff(ls(), c("cluster_bootstrap", "int_plot")))
